//
//  CZHomeWebViewController.swift
//  微博08
//
//  Created by apple on 16/3/10.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZHomeWebViewController: UIViewController {
    
    var addr: String?
    
    override func loadView() {
        view = webView
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        if addr == nil {
            return
        }
        
        // 加载网络地址
        let url = NSURL(string: addr!)!
        let request = NSURLRequest(URL: url)
        webView.loadRequest(request)
        
        // 设置导航栏
        setupNavigationbar()
    }
    
    private func setupNavigationbar() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", style: UIBarButtonItemStyle.Plain, target: self, action: "close")
    }
    
    @objc private func close() {
        self.dismissViewControllerAnimated(true, completion: nil)
    }

    // MARK: - 懒加载
    /// webView
    private lazy var webView: UIWebView = UIWebView()
}
